(function(){
    // 虽说用处和any差不多，但是any会关闭 类型检测 到这传值 和 返回值 可能是不同类型的值
    function fn<T>(a:T):T{
        return a;
    }
    fn(10)      //不指定泛型，TS可以自动对类型进行判断
    fn<string>('hello world')       //指定泛型

    function fn2<T,K>(a:T,b:K):T{
        console.log(b);
        return a;
    }
    let result = fn2(123,'hello world')
    let result2 = fn2<number,string>(123,'hello world')

    interface fnType{
        length:number;
        name:string;
    }
    function fn3<T extends fnType>(a:T):T{
        return a;
    }
    let result3 =  fn3({length:10,name:'hello world'})
    class myClass<T> {
        name:T;
        constructor(name:T){
            this.name = name;
        }
    }
    let mc = new myClass<string>('hello world')
})()